package PressItForGlory;

import java.awt.event.*;

import java.lang.Math;
import javax.swing.*;

import main.GameEngine;
import game.GenericGame;

public class PressItForGlory extends GenericGame {

	public PressItForGlory(GameEngine engine) {
		super(engine);
	}

	@Override
	public JPanel getPanel() {
		JPanel jp = new JPanel();
		JButton jb = new GloryButton("Press it for Glory!");

		jp.add(jb);
		
		return jp;
	}
	
	public String getName() {
		return "Press it for glory!";
	}
	
	private class GloryButton extends JButton implements ActionListener {
		private int times = 0;
		private String text;
		
		public GloryButton(String text){
			super(text);
			this.text = text;
			addActionListener(this);
		}
		
		@Override
		public void actionPerformed(ActionEvent arg0) {
			times++;
			this.setText("Glory for the " + times + getSuffix() + " time.");
		}
		
		private String getSuffix() {
			switch (Math.abs(times)) {
				case 1:
					return "st";
				case 2:
					return "nd";
				case 3:
					return "rd";
				default:
					return "th";
			}
		}
		
	}

}
